<template>
  <el-container>
    <el-header>
      <headPart></headPart>
    </el-header>
    <el-main>
      <template>
        <div class="w">
          <h2 class="title">
            <span class="el-icon-office-building"></span><i>房产信息</i>
          </h2>
          <mainPart ref="propertyList"></mainPart>
        </div>
      </template>
    </el-main>
    <el-footer>
      <footerPart></footerPart>
    </el-footer>
  </el-container>
</template>

<script>
import footerPart from "@/Layout/footer/index.vue";
import headPart from "@/Layout/head/index.vue";
import mainPart from "@/Layout/main/index.vue";
import { getAgentsDetail } from "@/api/post.js";
import { getCategorysDetail, getPropertiesDetail } from "@/api/hotel.js";
export default {
  components: {
    footerPart,
    headPart,
    mainPart,
  },
  data() {
    return {
      id: "",
    };
  },
  created() {
    console.log(40, this.$route);
    if (this.$route.path.includes("detail")) {
      this.getAgentsDetail();
    } else if (this.$route.params.id) {
      this.getCategorysDetail();
    } else {
      this.getPropertiesDetail();
    }
  },
  methods: {
    async getAgentsDetail() {
      const id = this.$route.params.id ? this.$route.params.id : "";
      const { data } = await getAgentsDetail(id);
      // console.log(38, data);
      this.$refs.propertyList.list = data.properties;
    },
    async getCategorysDetail() {
      const id = this.$route.params.id ? this.$route.params.id : "";
      const { data } = await getCategorysDetail(id);
      this.$refs.propertyList.list = data.properties;
      // console.log(52, data);
    },
    async getPropertiesDetail() {
      const { data } = await getPropertiesDetail(this.$route.query);
      this.$refs.propertyList.list = data;
      console.log(65, data);
    },
    // async getCategorys() {
    //   const res = await getCategorysDetail(this.$route.query);
    //   console.log(72, res);
    // },
  },
};
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.w {
  width: 1200px;
  margin: 0 auto;
  .title {
    text-align: left;
    text-indent: 2em;
    margin: 15px 0;
    font-weight: 400;
    color: orange;
    font-size: 20px;
    i {
      font-weight: 400;
    }
  }
}
</style>
